package com.hequ.merchant.banner.util;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;

/**
 * 裁剪图片工具类，支持大图片
 * Created by 柯尊诚 on 2015/10/30.
 * kzc
 */
public class CropImageUtil {

    private static CropImageUtil instance;

    public static CropImageUtil getInstance() {
        if (instance == null) {
            instance = new CropImageUtil();
        }
        return instance;
    }

    public void cropPicture(Activity activity, Uri imageUri, int requestCode) {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("image/*");
        intent.putExtra("crop", "true");
        intent.putExtra("aspectX", 2);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", 720);
        intent.putExtra("outputY", 360);
        intent.putExtra("scale", true);
        intent.putExtra("return-data", false);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        intent.putExtra("noFaceDetection", false); // no face detection
        activity.startActivityForResult(intent, requestCode);
    }
}
